package com.hsgene.shoppingcar.persistence;

import com.hsgene.shoppingcar.domain.ShoppingCarInfo;
import com.hsgene.shoppingcar.dto.SelectedPriceAndCountInfo;
import com.hsgene.shoppingcar.dto.ShoppingCarInfoDto;
import com.hsgene.shoppingcar.dto.ShoppingCarListInfo;
import com.hsgene.shoppingcar.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 购物车数据层
 *
 * @Author: wangxuefeng@hsgene.com
 * @Description:
 * @Date: Created in 15:49 2018/7/16
 * @Modified By:
 */
public interface ShoppingCarPersistence extends BaseMapper<ShoppingCarInfo> {
    /**
     * 插入和更新(同一件商品添加多次,直接更新)
     *
     * @param carInfo 物品信息
     * @return
     */
    int insertAndUpdate(@Param("shoppingCarInfo") ShoppingCarInfo carInfo);

    /**
     * 查询购物车
     *
     * @param userId 用户id
     * @return
     */
    List<ShoppingCarListInfo> queryShoppingCarByUserId(@Param("userId") String userId);

    /**
     * 批量删除
     *
     * @param ids 删除ids
     * @return
     */
    int deleteBatch(@Param("ids") String[] ids);

    /**
     * 更新购物车信息
     *
     * @param infoDtoList 更新信息
     * @return
     */
    boolean updateShoppingCar(@Param("infoDtoList") List<ShoppingCarInfoDto> infoDtoList);

    /**
     * 获取筛选物品的总价格
     *
     * @param userId 用户id
     * @return
     */
    SelectedPriceAndCountInfo getShoppingCarSelectedPrice(@Param("userId") String userId);

}
